package org.tlipoca.smuserdirectory.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.genntii.smdomain.dto.UserDirectoryDTO;
import org.genntii.smdomain.entity.UserDirectory;

import java.util.ArrayList;

@Mapper
public interface UserDirectoryMapper extends BaseMapper<UserDirectory> {

    @Select("select * from User_Directory where user_id = #{id};")
    ArrayList<UserDirectory> selectUserDirectoryByUserId(Long id);

    @Insert("insert into User_Directory (user_id, directory_name, directory_image, visible) values (#{userId}, #{directoryName}, #{directoryImage}, #{visible});")
    void insertUserDirectory(UserDirectoryDTO userDirectoryDTO);

    @Delete("delete from User_Directory where user_id = #{userId} and id = #{directoryId};")
    void deleteUserDirectory(@Param("directoryId") Long directoryId, @Param("userId") Long userId);

    void deleteUserDirectoryBatch(@Param("directoryIds") ArrayList<Long> directoryIds, @Param("userId") Long userId);

    void updateUserDirectory(@Param("dto") UserDirectoryDTO userDirectoryDTO, @Param("directoryId") Long directoryId,@Param("userId")Long userId);

    @Update("update User_Directory set visible = #{status} where id = #{directoryId};")
    void updateUserDirectoryStatus(@Param("directoryId") Long directoryId, @Param("status") Integer status);
}
